clear
clc
close all
hold on

lm=['s','o'];

gamma = [0.3 0.7];
L1_2 = load('new_anal_L1_g3f_2.txt');
L2_2 = load('new_anal_L2_g3f_2.txt');
L1_256 = load('new_anal_L1_g3f_256.txt');
L2_256 = load('new_anal_L2_g3f_256.txt');


% gamma = [0.5 0.5];
% L1_2 = load('new_anal_L1_g5f_2.txt');
% L2_2 = load('new_anal_L2_g5f_2.txt');
% L1_256 = load('new_anal_L1_g5f_256.txt');
% L2_256 = load('new_anal_L2_g5f_256.txt');


% gamma = [0.4 0.6];
% L1_2 = load('new_anal_L1_g4f_2.txt');
% L2_2 = load('new_anal_L2_g4f_2.txt');
% L1_256 = load('new_anal_L1_g4f_256.txt');
% L2_256 = load('new_anal_L2_g4f_256.txt');




number_of_packets = length(L1_2);
ticks = 2;
xax = 40:ticks:number_of_packets;

p=plot(xax,L1_2(40:ticks:number_of_packets),'-k')
set(p,'Marker',lm(1),'MarkerSize',4)
p=plot(xax,L2_2(40:ticks:number_of_packets),'--k')
set(p,'Marker',lm(1),'MarkerSize',4)


p=plot(xax,L1_256(40:ticks:number_of_packets),'-k')
set(p,'Marker',lm(2),'MarkerSize',4)
p=plot(xax,L2_256(40:ticks:number_of_packets),'--k')
set(p,'Marker',lm(2),'MarkerSize',4)


axis([40 number_of_packets 0 1])

legend_h = legend('','','','');

% Legend fix
label_1=strcat('L1, \Gamma_1=',num2str(gamma(1)),', FF(2^1)',NaN,NaN,NaN,NaN,NaN);
label_2=strcat('L1 & L2, \Gamma_1=',num2str(gamma(1)),', FF(2^1)');
label_3=strcat('L1, \Gamma_1=',num2str(gamma(1)),', FF(2^8)',NaN,NaN,NaN,NaN,NaN);
label_4=strcat('L1 & L2, \Gamma_1=',num2str(gamma(1)),', FF(2^8)');

length(label_3)
length(label_4)

%resize_legend(legend_h,0.7);
set(legend_h,'String',[label_1;label_2;label_3;label_4],'location','SouthEast')
set(legend_h,'interpreter','tex')
xlabel('Total number of received packets [-]')
ylabel('Decoding probability [-]')
set(gca,'XTick',0:10:number_of_packets)
set(gca,'YTick',0:0.1:1)




grid()
pbaspect([2.5 1 1])
% Save plot
figname=strcat('uep_new_analytic','_g1_',num2str(gamma(1)*100),'_g2_',num2str(gamma(2)*100),'.eps');
print(gcf,'-depsc2',figname)


hold off